package org.jeecg.modules.controller;

import org.jeecg.modules.pojo.Purchase;
import org.jeecg.modules.pojo.PurchaseGoods;
import org.jeecg.modules.service.PurchaseGoodsService;
import org.jeecg.modules.service.PurchaseService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @company: yaorange
 * @author: Andy.Li
 * @Date: 2022.04.27 16:46:13
 */
@RestController
@RequestMapping("/purchaseListGoods")
public class PurchaseGoodsController {
    @Resource
    private PurchaseGoodsService purchaseGoodsService;
    @Resource
    private PurchaseService purchaseService;

    @PostMapping("/goodsList")
    //@RequestParam("purchaseListId")
    public ResponseEntity<?> getGoodsList(@RequestBody Purchase purchase) {

        List<PurchaseGoods> list = purchaseGoodsService.getGoods(purchase.getPurchaseListId());
        return ResponseEntity.ok(list);
    }

    @PostMapping("delete")
    public ResponseEntity<?> delPurchaseList(@RequestBody Purchase purchase) {

        int i = purchaseService.delById(purchase.getPurchaseListId());
        return ResponseEntity.ok(i);
    }

    @PostMapping("/getPurchaseInfoByPurNum")
    public ResponseEntity<?> getPurchaseInfoByPurNum(@RequestBody Purchase purchase) {
        List<PurchaseGoods> list = purchaseGoodsService.getPurchaseInfoByPurNum(purchase);
        return ResponseEntity.ok(list);
    }
}
